package com.lst.demo.recycleview.adapter;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lst.demo.R;
import com.lst.demo.recycleview.bean.PersonBean;

import java.util.List;

/**
 * 列表
 * create by Lst
 * on 2020/4/8
 */
public class ListLvRecycleAdapter extends RecyclerView.Adapter<ListLvRecycleAdapter.ViewHolder> {

    private Context context;
    private List<PersonBean> listdata;

    public ListLvRecycleAdapter(Context context, List<PersonBean> listdata) {
        this.context = context;
        this.listdata = listdata;
    }

    @NonNull
    @Override
    public ListLvRecycleAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_lv, viewGroup, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ListLvRecycleAdapter.ViewHolder viewHolder, int i) {

    }

    @Override
    public int getItemCount() {
        return listdata.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder {

        public ViewHolder(View itemView) {
            super(itemView);

        }

    }


    //Recycleview点击事件
    private ItemClickListener mItemClickListener;

    public interface ItemClickListener {
        public void onItemClick(int position);
    }

    public void setOnItemClickListener(ItemClickListener itemClickListener) {
        this.mItemClickListener = itemClickListener;

    }


}
